/// @tags: Sqrt
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
using std::sort;

namespace BlueQuantum {

int const N = 1e6 + 5, SIZ = 1e3 + 5;

template <typename T>
inline T &read(T &x) {
  x = 0;
  bool f = false;
  short ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = true;
    ch = getchar();
  }
  while (isdigit(ch)) x = x * 10 + (ch ^ '0'), ch = getchar();
  if (f) x = -x;
  return x;
}

int n, q, siz, blk;
int a[N], b[N], L[SIZ], R[SIZ], id[N], tag[SIZ];

inline void build() {
  siz = sqrt(n);
  blk = (n - 1) / siz + 1;
  for (int i = 1; i <= blk; ++i) L[i] = (i - 1) * siz + 1, R[i] = i * siz;
  R[blk] = n;
  for (int i = 1; i <= blk; ++i) {
    for (int j = L[i]; j <= R[i]; ++j) b[j] = a[j], id[j] = i;
  }
  for (int i = 1; i <= blk; ++i) sort(b + L[i], b + R[i] + 1);
}

inline void modify(int x, int y, int k) {
  if (id[x] != id[y]) {
    for (int i = x; i <= R[id[x]]; ++i) a[i] += k;
    memcpy(b + L[id[x]], a + L[id[x]], sizeof(int) * (R[id[x]] - L[id[x]] + 1));
    sort(b + L[id[x]], b + R[id[x]] + 1);
    for (int i = L[id[y]]; i <= y; ++i) a[i] += k;
    memcpy(b + L[id[y]], a + L[id[y]], sizeof(int) * (R[id[y]] - L[id[y]] + 1));
    sort(b + L[id[y]], b + R[id[y]] + 1);
    for (int i = id[x] + 1; i <= id[y] - 1; ++i) tag[i] += k;
  } else {
    for (int i = x; i <= y; ++i) a[i] += k;
    memcpy(b + L[id[x]], a + L[id[x]], sizeof(int) * (R[id[x]] - L[id[x]] + 1));
    sort(b + L[id[x]], b + R[id[x]] + 1);
  }
}

inline int query(int x, int y, int k) {
  int res = 0;
  if (id[x] != id[y]) {
    for (int i = x; i <= R[id[x]]; ++i)
      if (tag[id[x]] + a[i] >= k) res++;
    for (int i = L[id[y]]; i <= y; ++i)
      if (tag[id[y]] + a[i] >= k) res++;
    for (int i = id[x] + 1; i <= id[y] - 1; ++i)
      res += R[i] + (b - std::lower_bound(b + L[i], b + R[i] + 1, k - tag[i])) + 1;
  } else {
    for (int i = x; i <= y; ++i)
      if (tag[id[x]] + a[i] >= k) res++;
  }
  return res;
}

inline int main() {
  read(n), read(q);
  for (int i = 1; i <= n; ++i) read(a[i]);
  build();
  char opt[2];
  for (int x, y, k; q; --q) {
    scanf("%s", opt);
    read(x), read(y), read(k);
    switch (opt[0]) {
      case 'M':
        modify(x, y, k);
        break;
      case 'A':
        printf("%d\n", query(x, y, k));
    }
  }
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("P2801 教主的魔法.in", "r", stdin);
  freopen("P2801 教主的魔法.out", "w", stdout);
#endif
#endif

  return BlueQuantum::main();
}